Skip to main content

Tauri

· 2 min read

You can build native application which is more smaller, faster and more secure using HTML, JavaScript and CSS. After checked the creators' philosophy and features, I believe that it will be the replacement of ElectronJS.

Acutually, Tauri Documentation is good reference to start and every steps what need to do in there. You can check from offcial document, here I would like to make my own note. Please note tips described in document

Window Enviroment System Dependencies Setup#

  1. Microsoft Visual Studio C++ build tools and install C++ Build Tools package
  2. Node.js and Package Manager
  3. RustC and Cargo Package
  4. WebView2 and use Evergreen Bootstrapper

Create React Project#

I used 'create-react-app' to build sample web app and add Tauri CLI Package into my application.

create-react-app tauri-desktopcd tauri-desktopyarn add -D @tauri-apps/cli

after added Taur CLI package , we need to change package.json file

"scripts": {    "start": "react-scripts start",    "build": "react-scripts build",    "test": "react-scripts test",    "eject": "react-scripts eject",    "tauri": "tauri" // Add Tauri CLI Script},

Start Tauri and Tauri will ask some information on console. You need to put whatever you want.

yarn tauri init
What is your app name?: tauri-desktopWhat should the window title be?: Happy Hours with TauriWhere are your web assets (HTML/CSS/JS) located, relative to the "<current dir>/src-tauri" folder that will be created?: ../buildWhat is the url of your dev server?: http://localhost:4200...dependency:npm-packages "@tauri-apps/cli" is already installed +781msDone in 163.78s.

Now Tauri CLI is succefully integrated with my application. We can start Tauri Window

yarn tauri dev

It will take some time for first time run. Rust package manager is downloading packages.

App Publishing#

Now my application is ready to package. We need to run bundlers' build command

yarn tauri build

This command will embed your web assets into a single binary with your Rust code. The binary itself will be located in target/release/[app name], and installers will be located in target/release/bundle/

Regards